package app.common.utils.cjt.ao;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * <b>订单推送</b>
 * @author feizns
 * @since 2023/3/21
 */
@Data
public class GoodsGoodsPushAo {

    public static void main(String[] args) {
        System.out.println(JSON.toJSONString(new GoodsGoodsPushAo()));
    }

    private String goods_no;
    private String goods_name;
    private String short_name;
    private Boolean auto_create_bc;
    private String class_name;
    private String brand_name;
    private String unit_name;
    private String aux_unit_name;
    private String goods_type;
    private String alias;
    private String pinyin;
    private String origin;
    private String remark;
    private String prop1;
    private String prop2;
    private String prop3;
    private String prop4;
    private String prop5;
    private String prop6;
    private String flag_name;

    private String spec_no;
    private String spec_name;
    private String spec_code;
    private String barcode;
    private String img_url;
    private Integer pack_score;
    private Double lowest_price;
    private Integer is_single_batch;
    private Integer goods_label;

    /**
     * 内部属性1
     */
    private String innerProp1;

    /**
     * 内部属性2
     */
    private String innerProp2;

    /**
     * 内部属性3
     */
    private String innerProp3;

    /**
     * 内部属性4
     */
    private String innerProp4;

    /**
     * 内部属性5
     */
    private String innerProp5;

    /**
     * 内部属性6
     */
    private String innerProp6;

    /**
     * 内部单位名称
     */
    private String inner_unit_name;

    /**
     * 内部辅助单元名称
     */
    private String inner_aux_unit_name;

    public Map<String, Object> toSubMap() {
        Map<String, Object> map = new TreeMap<>();
        map.put("spec_no",spec_no);
        map.put("spec_name",spec_name);
        map.put("spec_code",spec_code);
        map.put("barcode",barcode);
        map.put("pack_score",pack_score);
        map.put("lowest_price",lowest_price);
        map.put("is_single_batch",is_single_batch);
        map.put("goods_label;",goods_label);
        map.put("img_url", img_url);
        map.put("prop1", innerProp1);
        map.put("prop2", innerProp2);
        map.put("prop3", innerProp3);
        map.put("prop4", innerProp4);
        map.put("prop5", innerProp5);
        map.put("prop6", innerProp6);
        map.put("unit_name", inner_unit_name);
        map.put("inner_aux_unit_name", inner_aux_unit_name);
        return map;
    }

    public Map<String, Object> toMap() {
        Map<String, Object> map = new TreeMap<>();
        map.put("goods_no",goods_no );
        map.put("goods_name",goods_name );
        map.put("short_name",short_name );
        map.put("auto_create_bc",auto_create_bc );
        map.put("class_name",class_name );
        map.put("brand_name",brand_name );
        map.put("unit_name",unit_name );
        map.put("aux_unit_name",aux_unit_name );
        map.put("goods_type", goodsTypeMapper.get(goods_type) );
        map.put("alias",alias );
        map.put("pinyin",pinyin );
        map.put("origin",origin );
        map.put("remark",remark );
        map.put("prop1",prop1 );
        map.put("prop2",prop2 );
        map.put("prop3",prop3 );
        map.put("prop4",prop4 );
        map.put("prop5",prop5 );
        map.put("prop6",prop6 );
        map.put("flag_name",flag_name );
        return map;
    }

    /**
     * 转换成json
     * @return json
     */
    public String toData() {
        return JSON.toJSONString(Arrays.asList(toMap(), Collections.singletonList(toSubMap())));
    }

    public static final Map<String, Integer> goodsTypeMapper = Collections.unmodifiableMap(new HashMap<String, Integer>(){{
        put("分装箱", 8);
        put("固定资产", 6);
        put("虚拟商品", 5);
        put("周转材料", 4);
        put("包装物", 3);
        put("原材料", 2);
        put("销售货品", 1);
        put("其它", 0);
    }});

}

